*------------------------------PLEASE READ-------------------------------------*
/*
REPLICATION FILE FOR TABLE E1-E6
AUTHOR: ZHENHUAN LEI & YISHUANG LI
DATE: 11/13/2023
SOFTWARE: STATA 17 SE OPERATED ON WINDOWS 11

STATA PACKAGE NEEDED: 
	ssc install estout, replace 
	ssc install coefplot, replace
*/


*-------------------------- Set up the environment ---------------------------*

clear 

use ../data/case_data.dta

*** Define control variables***	
	
	global cont_base i.local_plaintiff i.dispute c.stake_bi i.court_level i.other_pro  
	
	global cont_firm i.plaintiff##c.total_return_rate i.plaintiff##c.debt_rate i.plaintiff##c.lemploy i.plaintiff##c.firm_age i.plaintiff##c.net_profit i.plaintiff##c.net_cash_flow i.plaintiff##c.reg_cap_bi i.plaintiff##i.firm_pc i.firm1_local##c.total_return_rate i.firm1_local##c.debt_rate i.firm1_local##c.lemploy i.firm1_local##c.firm_age i.firm1_local##c.net_profit i.firm1_local##c.net_cash_flow i.firm1_local##c.reg_cap_bi i.firm1_local##i.firm_pc				  
	
	global pro_cont pro_pop pro_gdp_percapita pro_rev_percapita pro_exp_percapita pro_growth pro_unemp rev_vat total_ipo 
	
	global cont_city population_hr_c gdp_percapita_c publicfinance_income_c gdp_growth_c city_total_ipo tax_vadded_c investment_fixed_c population_unemployed_c gdp_secondary_c gdp_tertiary_c publicfinance_expenditure_c

*	Non-Missing subgroup 
	gen non_mi_pro = (plaintiff != . & dispute != . & stake_bi != . & court_level != . & other_pro != . & total_return_rate != . & debt_rate != . & lemploy != . & firm_age != . & net_profit != . & net_cash_flow != . & reg_cap_bi!= . & pro_gdp_percapita != . & pro_pop != . & pro_rev_percapita != . & pro_exp_percapita != . & pro_growth != . & total_ipo != . & rev_vat != . & pro_unemp != .)

	gen non_mi_city = (plaintiff != . & dispute != . & stake_bi != . & court_level != . & other_pro != . & total_return_rate != . & debt_rate != . & lemploy != . & firm_age != . & net_profit != . & net_cash_flow != . & reg_cap_bi!= . & gdp_percapita_c != . & population_hr_c != . & publicfinance_income_c != . & gdp_growth_c != . & city_total_ipo != . & tax_vadded_c != . & investment_fixed_c != . & population_unemployed_c != . & gdp_secondary_c != . & gdp_tertiary_c != . & publicfinance_expenditure_c != .)
			   
*** Limit the data sample ***
	gen data_sample = (court_level == 2 | court_level == 1) & arbitration == 0 & reconcile == 0 
	* Drop intermediate courts in municipalities
	replace data_sample = 0 if court_level == 2 & municipal == 1  
	keep if data_sample == 1 		

*-------------------------- Regression analysis -------------------------------*

***Table E1***

preserve 

keep if  ((trial_year >= reform_50_year & accept_year < reform_50_year) | trial_year < reform_50_year) & non_mi_city == 1 
	
	eststo clear
	eststo: qui areg local_win_low centralize_city50 i.pro_code##i.trial_year, a(city_id) vce(cluster city_id) 
	eststo: qui areg local_win_low centralize_city50 $cont_base i.pro_code##i.trial_year, a(city_id) vce(cluster city_id) 
	eststo: qui areg local_win_low centralize_city50 $cont_base $cont_firm i.pro_code##i.trial_year, a(city_id) vce(cluster city_id)  
	eststo: qui areg local_win_low centralize_city50 $cont_base $cont_city $cont_firm i.pro_code##i.trial_year , a(city_id) vce(cluster city_id)  
	esttab , se b(3) t(3) star(* 0.1 ** 0.05 *** 0.01) keep(centralize_city50) replace
	
restore 			   


preserve
	
keep if non_mi_city == 1 

***Table E2*** 

	eststo clear
	eststo: qui areg local_win_low pl_centralize50 i.pro_code##i.trial_year , a(city_id) vce(cluster city_id)  
	eststo: qui areg local_win_low pl_centralize50 $cont_base i.pro_code##i.trial_year , a(city_id) vce(cluster city_id)  
	eststo: qui areg local_win_low pl_centralize50 $cont_base $cont_firm i.pro_code##i.trial_year , a(city_id) vce(cluster city_id)  
	eststo: qui areg local_win_low pl_centralize50 $cont_base $cont_city $cont_firm i.pro_code##i.trial_year , a(city_id) vce(cluster city_id) 
	esttab , se b(3) t(3) scalars(N_clust) star(* 0.1 ** 0.05 *** 0.01) keep(pl_centralize50) replace
	
***Table E5*** 

	eststo clear
	eststo: qui areg enforce_1y_low centralize_city50 $cont_base $cont_city $cont_firm i.pro_code##i.trial_year, a(city_id) vce(cluster city_id) 
	eststo: qui areg enforce_1y_low centralize_city50##i.other_pro $cont_base $cont_city $cont_firm i.pro_code##i.trial_year, a(city_id) vce(cluster city_id) 
        lincom 1.centralize_city50 + 1.centralize_city50#1.other_pro
	eststo: qui areg enforce_1y_low centralize_city0 $cont_base $cont_city $cont_firm i.pro_code##i.trial_year, a(city_id) vce(cluster city_id) 
	eststo: qui areg enforce_1y_low centralize_city0##i.other_pro $cont_base $cont_city $cont_firm i.pro_code##i.trial_year, a(city_id) vce(cluster city_id) 
        lincom 1.centralize_city0 + 1.centralize_city0#1.other_pro
	esttab , se b(3) t(3) star(* 0.1 ** 0.05 *** 0.01) keep(centralize_city50 centralize_city0 1.centralize_city50* 1.centralize_city0*)

***Table E6*** 

	eststo clear
	eststo: qui areg enforce_quality_low centralize_city50 $cont_base $cont_city $cont_firm i.pro_code##i.trial_year, a(city_id) vce(cluster city_id) 
	eststo: qui areg enforce_quality_low centralize_city50##i.other_pro $cont_base $cont_city $cont_firm i.pro_code##i.trial_year, a(city_id) vce(cluster city_id) 
        lincom 1.centralize_city50 + 1.centralize_city50#1.other_pro
	eststo: qui areg enforce_quality_low centralize_city0 $cont_base $cont_city $cont_firm i.pro_code##i.trial_year, a(city_id) vce(cluster city_id) 
	eststo: qui areg enforce_quality_low centralize_city0##i.other_pro $cont_base $cont_city $cont_firm i.pro_code##i.trial_year, a(city_id) vce(cluster city_id) 
        lincom 1.centralize_city0 + 1.centralize_city0#1.other_pro
	esttab  , se b(3) t(3) star(* 0.1 ** 0.05 *** 0.01) keep(centralize_city50 centralize_city0 1.centralize_city50* 1.centralize_city0*)

restore

preserve 

keep if non_mi_pro & !missing_data == 1 
	
***Table E3*** 

	eststo clear
	eststo: qui areg local_win_low centralize_pro i.trial_year , a(pro_code) vce(cluster pro_code)   
	eststo: qui areg local_win_low centralize_pro $cont_base i.trial_year , a(pro_code) vce(cluster pro_code)   
	eststo: qui areg local_win_low centralize_pro $cont_base $cont_firm i.trial_year , a(pro_code) vce(cluster pro_code)   
	eststo: qui areg local_win_low centralize_pro $cont_base $pro_cont $cont_firm i.trial_year , a(pro_code) vce(cluster pro_code)
	esttab , se b(3) t(3) star(* 0.1 ** 0.05 *** 0.01) keep(centralize_pro) replace
 
*** Table E4*** 

	eststo clear
	eststo: qui areg local_win_low centralize_pro##centralize_city50 i.trial_year, a(pro_code) vce(cluster pro_code) 
     lincom 1.centralize_pro + 1.centralize_pro#1.centralize_city50
	eststo: qui areg local_win_low centralize_pro##centralize_city50 $cont_base i.trial_year, a(pro_code) vce(cluster pro_code)
     lincom 1.centralize_pro + 1.centralize_pro#1.centralize_city50
	eststo: qui areg local_win_low centralize_pro##centralize_city50 $cont_base $cont_firm i.trial_year, a(pro_code) vce(cluster pro_code)
     lincom 1.centralize_pro + 1.centralize_pro#1.centralize_city50
	eststo: qui areg local_win_low centralize_pro##centralize_city50 $cont_base $pro_cont $cont_firm i.trial_year, a(pro_code) vce(cluster pro_code)
     lincom 1.centralize_pro + 1.centralize_pro#1.centralize_city50
	esttab , se b(3) t(3) star(* 0.1 ** 0.05 *** 0.01) keep(1.centralize_pro*) 

restore


 